/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.psdk.local;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.text.TextUtils;
import com.qihoo.psdk.app.QStatActivity;
import com.qihoo.psdk.n;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class h {
    public static void a(Context paramContext, g paramg, String paramString) {
        try {
            int i = 1;
            String str = com.qihoo.psdk.util.a.a(paramString);
            int j = new Random().nextInt();
            if (j < 0)
                j = -j;
            Intent localIntent = new Intent(paramContext, QStatActivity.class);
            localIntent.putExtra("url", paramg.p);
            localIntent.putExtra("activity", paramg.q);
            localIntent.putExtra("application", paramg.r);
            localIntent.putExtra("msgId", str);
            localIntent.putExtra("startype", paramg.v);
            localIntent.putExtra("service", paramg.w);
            if (!(TextUtils.isEmpty(paramg.s)))
                localIntent.putExtra("custom", paramg.s);
            localIntent.putExtra("app", paramg.t);
            localIntent.putExtra("notifyId", j);
            PendingIntent localPendingIntent = PendingIntent.getActivity(paramContext, j, localIntent, 268435456);
            Notification localNotification = new Notification(a(paramContext, paramg.d), paramg.c,
                    System.currentTimeMillis());
            localNotification.flags |= 16;
            if (!(TextUtils.isEmpty(paramg.t))) {
                localObject = new a(paramg.t);
                ((a) localObject).a();
                int k = n.c(paramContext, ((a) localObject).d);
                if (k >= ((a) localObject).e)
                    i = 0;
                else
                    localNotification.setLatestEventInfo(paramContext, paramg.e, paramg.f, localPendingIntent);
            }
            else {
                localNotification.setLatestEventInfo(paramContext, paramg.e, paramg.f, localPendingIntent);
            }
            if (paramg.n)
                localNotification.defaults |= 1;
            if (paramg.l)
                localNotification.defaults |= 2;
            if (paramg.m)
                localNotification.defaults |= 4;
            if (paramg.u) {
                if (!(n.a(paramContext, paramg.r))) {
                    localIntent.addFlags(268435456);
                    paramContext.startActivity(localIntent);
                }
            }
            else if (i != 0) {
                localObject = (NotificationManager) paramContext.getSystemService("notification");
                ((NotificationManager) localObject).notify(j, localNotification);
            }
            Object localObject = new HashMap();
            ((HashMap) localObject).put("msgId", str);
            if (i == 0)
                ((HashMap) localObject).put("display", "false");
            com.qihoo.psdk.a.a("arrived", (Map) localObject);
        } catch (Exception localException) {
            com.qihoo.psdk.util.h.a("QNotifyProcess", localException);
        } catch (Error localError) {
            com.qihoo.psdk.util.h.a("QNotifyProcess", localError);
        }
    }

    private static int a(Context paramContext, String paramString) {
        int i = 0;
        PackageManager localPackageManager = null;
        String str = "";
        PackageInfo localPackageInfo = null;
        try {
            localPackageManager = paramContext.getPackageManager();
            str = paramContext.getPackageName();
            i = paramContext.getResources().getIdentifier(paramString, "drawable", str);
        } catch (Exception localException1) {
            com.qihoo.psdk.util.h.a("QNotifyProcess", localException1);
        } catch (Error localError1) {
            com.qihoo.psdk.util.h.a("QNotifyProcess", localError1);
        }
        if (i == 0)
            try {
                localPackageInfo = localPackageManager.getPackageInfo(str, 0);
                i = localPackageInfo.applicationInfo.icon;
                com.qihoo.psdk.util.h.a("QNotifyProcess", "pkg: " + str + ", id: " + i);
            } catch (Exception localException2) {
                com.qihoo.psdk.util.h.a("QNotifyProcess", localException2);
            } catch (Error localError2) {
                com.qihoo.psdk.util.h.a("QNotifyProcess", localError2);
            }
        return i;
    }
}